package com.bianguo.android.functiondemo.utils;

import android.app.Activity;
import android.content.Context;
import android.net.Uri;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;

public class GlideUtil {

    public static final void loadImage(Activity mContext, String imageUrl, ImageView imageView, int holderImage) {
        RequestOptions requestOptions = new RequestOptions();
        if (holderImage > 0) {
            requestOptions.placeholder(holderImage);
        }
        Glide.with(mContext)
                .load(imageUrl)
                .thumbnail(0.1f)
                .apply(requestOptions)
                .into(imageView);
    }

    public static void loadImage(Context mContext, String imageUrl, ImageView imageView, int holderImage) {
        RequestOptions requestOptions = new RequestOptions();
        if (holderImage > -1) {
            requestOptions.placeholder(holderImage);
        }
        Glide.with(mContext)
                .load(imageUrl)
                .thumbnail(0.1f)
                .apply(requestOptions)
                .into(imageView);
    }

    public static void loadImage(Activity mContext, int imageId, ImageView imageView, int holderImage) {
        RequestOptions requestOptions = new RequestOptions();
        if (holderImage > -1) {
            requestOptions.placeholder(holderImage);
        }
        Glide.with(mContext)
                .load(imageId)
                .thumbnail(0.1f)
                .apply(requestOptions)
                .into(imageView);
    }

    public static void loadImage(Context mContext, int imageId, ImageView imageView, int holderImage) {
        RequestOptions requestOptions = new RequestOptions();
        if (holderImage > -1) {
            requestOptions.placeholder(holderImage);
        }
        Glide.with(mContext)
                .load(imageId)
                .thumbnail(0.1f)
                .apply(requestOptions)
                .into(imageView);
    }

    public static final void loadImage(Activity mContext, Uri imageUri, ImageView imageView, int holderImage) {
        RequestOptions requestOptions = new RequestOptions();
        if (holderImage > 0) {
            requestOptions.placeholder(holderImage);
        }
        Glide.with(mContext)
                .load(imageUri)
                .thumbnail(0.1f)
                .apply(requestOptions)
                .into(imageView);
    }

    public static final void loadImage(Context mContext, Uri imageUri, ImageView imageView, int holderImage) {
        RequestOptions requestOptions = new RequestOptions();
        if (holderImage > 0) {
            requestOptions.placeholder(holderImage);
        }
        Glide.with(mContext)
                .load(imageUri)
                .thumbnail(0.1f)
                .apply(requestOptions)
                .into(imageView);
    }
}
